package com.xasz.text2vec.service.impl;

import com.xasz.text2vec.dao.entity.DaySearch;
import com.xasz.text2vec.dao.entity.KnowledgeBase;
import com.xasz.text2vec.dao.mapper.DaySearchMapper;
import com.xasz.text2vec.dao.mapper.KnowledgeBaseMapper;
import com.xasz.text2vec.dto.KnowledgeDTO;
import com.xasz.text2vec.service.DaySearchService;
import com.xasz.text2vec.service.KnowledgeBaseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xasz.text2vec.utils.ToPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.crypto.Data;
import java.sql.Date;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cai
 * @since 2023-06-29
 */
@Service
public class KnowledgeBaseServiceImpl extends ServiceImpl<KnowledgeBaseMapper, KnowledgeBase> implements KnowledgeBaseService {

    @Autowired
    private KnowledgeBaseMapper knowledgeBaseMapper;

    @Autowired
    private DaySearchMapper daySearchMapper;

    @Override
    public KnowledgeBase selectById(int id,String qContent) {
        //查询回答
        KnowledgeBase knowledgeBase = knowledgeBaseMapper.selectById(id);
        //记录查询操作
        DaySearch daySearch = konwledgeToDaySearch(knowledgeBase,qContent);
        daySearchMapper.insert(daySearch);

        return knowledgeBase;
    }

    public DaySearch konwledgeToDaySearch(KnowledgeBase knowledgeBase,String qContent){
        DaySearch daySearch=new DaySearch();
        daySearch.setCreateUser("测试者");
        daySearch.setQContent(qContent);
        daySearch.setQCatgory(knowledgeBase.getCategory());
        daySearch.setSlecetContentid(knowledgeBase.getId());
        return daySearch;
    }
}
